<template>
  <div id="app">
    <!-- 搜索 -->
    <div class="home_search" v-if="isHideSearch">
      <van-search
        v-model="search_value"
        background="#fff"
        placeholder="请输入搜索关键字"
      />
    </div>

    <router-view />
    <van-tabbar
      route
      v-model="active"
      active-color="#ee0a24"
      inactive-color="#000"
    >
      <van-tabbar-item to="/" icon="wap-home-o">首页</van-tabbar-item>
      <van-tabbar-item to="/special" icon="search">专题</van-tabbar-item>
      <van-tabbar-item to="/category" icon="list-switch">分类</van-tabbar-item>
      <van-tabbar-item to="/cart" icon="shopping-cart-o"
        >购物车</van-tabbar-item
      >
      <van-tabbar-item to="/user" icon="contact-o">我的</van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
export default {
  data() {
    return {
      value: 5,
      active: "",
      search_value: "",
      isHideSearch: true,
    };
  },
  watch: {
    $route: {
      handler(newVal, oldVal) {
        this.isHideSearch = !(newVal.path == "/user" || newVal.path == "/cart");
      },
      immediate:true, //立即监听
      // deep:true//深度简体
    },
  },
};
</script>

<style>
body {
  background-color: #fff;
}

</style>
